<template>
    <div class="big-box">
        <div class="header">
            <img src="../../../../../assets/bigScreen/header3.png" alt="" />
            <div class="backBox" @click="goBack"></div>
        </div>
        <div class="backToBox">
            <div class="backTo" @click="gotoHome">
                <div>返回总窗口</div>
            </div>
            <div class="backTo" @click="backToOne">
                <div>返回上一页</div>
            </div>
        </div>
        <div class="centerBox">
            <div class="sreenTitle">经纪人</div>
            <div class="center">

                <!-- 筛选区 -->
                <div class="filter-box">
                    <div class="filter-title-box">
                        <div class="filter-title">筛选条件</div>
                        <div class="filter-input-box">
                            <div class="filter-input">
                                <input type="text" placeholder="请输入关键词" v-model="params.name" @keydown="onkeydown" />
                            </div>
                            <div class="filter-btn" @click="getList">搜索</div>
                        </div>
                    </div>
                    <div class="filter-container">
                        <div class="filter-type" v-for="(item, index) in typeList" :style="{ height: item.showMore ? 'initial' : '55px' }">
                            <div class="filter-type-title">{{ item.title }}</div>
                            <div :class="['filter-item', typeIds[index] == null ? 'active' : '']"
                                @click="params.number=1;setType(index, {name: null,id: null},item.fields)">全部</div>
                            <div v-for="sItem in item.list" :class="['filter-item', typeIds[index] == sItem.id ? 'active' : '']" :key="sItem.id"
                                @click="params.number=1;setType(index, sItem,item.fields)">
                                {{ sItem.name }}
                            </div>
                            <div class="filter-more-btn" @click="item.showMore = !item.showMore">
                                <span>更多分类</span>
                                <img :style="{ transform: item.showMore ? 'scaleY(-1)' : 'scaleY(1)' }" src="../../../../../assets/down.png" alt="" />
                            </div>
                        </div>
                        <div class="filter-type" :style="{ height: arearShowMore ? 'initial' : '55px' }">
                            <div class="filter-type-title">所在地</div>
                            <div style="width: calc(100% - 9rem - 40px);">
                                <div :class="areaIndex == index ? 'filter-item active' : 'filter-item'" v-for="(item, index) in areadata[0].children"
                                    @click="areaIndex = index; params.number=1;getOrg()" :key="index">
                                    <span v-if="item.name=='市直属'">{{areadata[0].name}}</span>
                                    <span v-else>{{item.name}}</span>
                                </div>
                                <div :class="areaIndex == -1 ? 'filter-item active' : 'filter-item'" @click="areaIndex = -1; params.number=1;getOrg()">
                                    <span>其他</span>
                                </div>
                            </div>
                            <div class="filter-more-btn" @click="arearShowMore = !arearShowMore">
                                <span>更多分类</span>
                                <img :style="{ transform: arearShowMore ? 'scaleY(-1)' : 'scaleY(1)' }" src="../../../../../assets/down.png" alt="" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="broker-container">
                    <div class="broker-item" v-for="(v,k) in resultList" @click="toPage('/bigScreen/brokerDetail?id=' + v.id)">
                        <div class="broker-img">
                            <!-- <img :src="v.logo" alt="" /> -->
                            <img :src=" v.logo.indexOf('http')== -1? baseUrl + v.logo : v.logo" v-if="v.logo" alt="">
                            <img src="../../../../../assets/photo.png" v-else alt="">
                        </div>
                        <div class="broker-name">{{ v.name }}</div>
                        <div class="broker-text two-lines">
                            <div class="broker-text-item">
                                <img src="../../../../../assets/broker-phone.png" alt="" />
                                <span>{{ v.tel }}</span>
                            </div>
                            <div class="broker-text-item">
                                <img src="../../../../../assets/broker-map.png" alt="" />
                                <span :title="v.work">{{ v.work }}</span>
                            </div>
                        </div>
                        <!-- <div class="broker-btn" @click.stop="gotoChat(v)">立即咨询</div> -->
                    </div>
                    <no-data v-if="!resultList.length" />
                </div>
                <div class="pagination-box">
                    <a-pagination :showSizeChanger='false' v-model:current="params.number" v-model:pageSize="params.size" :total="params.total"
                        @change="onShowSizeChange" />
                </div>
            </div>
            <!-- 找需求 -->
            <div v-if="tabIndex == 2">
                <!-- 筛选区 -->
                <div class="filter-box">
                    <div class="filter-title-box">
                        <div class="filter-title">筛选条件</div>
                        <!-- <div class="adds" @click="toPage('gainAdd2')">立即发布</div> -->
                        <div class="filter-input-box">
                            <div class="filter-input"><input type="text" placeholder="请输入关键词" v-model="params2.name" @keydown="onkeydown2" />
                            </div>
                            <div class="filter-btn" @click="getListDem('refresh')">搜索</div>
                        </div>
                    </div>
                    <div class="filter-container">
                        <div class="filter-type" v-for="(item, index) in typeList2" :style="{ height: item.showMore ? 'initial' : '55px' }">
                            <div class="filter-type-title">{{ item.title }}</div>
                            <div :class="['filter-item', typeIds2[index] == null ? 'active' : '']"
                                @click="params2.number=1;setType2(index, { name: null, id: null }, item.fields)">全部</div>
                            <div v-for="sItem in item.list" :class="['filter-item', typeIds2[index] == sItem.id ? 'active' : '']" :key="sItem.id"
                                @click="params2.number=1;setType2(index, sItem, item.fields)">
                                {{ sItem.name }}
                            </div>
                            <div class="filter-more-btn" @click="item.showMore = !item.showMore">
                                <span>更多分类</span>
                                <img :style="{ transform: item.showMore ? 'scaleY(-1)' : 'scaleY(1)' }" src="../../../../../assets/down.png" alt="" />
                            </div>
                        </div>
                        <div class="filter-type" :style="{ height: arearShowMore ? 'initial' : '55px' }">
                            <div class="filter-type-title">所在地</div>
                            <div style="width: calc(100% - 11rem - 40px);">
                                <div :class="areaIndex == index ? 'filter-item active' : 'filter-item'" v-for="(item, index) in areadata[0].children"
                                    @click="areaIndex = index; params2.number=1;getOrg1()" :key="index">
                                    <span v-if="item.name=='市直属'">{{areadata[0].name}}</span>
                                    <span v-else>{{item.name}}</span>
                                </div>
                                <div :class="areaIndex == -1 ? 'filter-item active' : 'filter-item'" @click="areaIndex = -1; params2.number=1;getOrg1()">
                                    <span>其他</span>
                                </div>
                            </div>
                            <div class="filter-more-btn" @click="arearShowMore = !arearShowMore">
                                <span>更多分类</span>
                                <img :style="{ transform: arearShowMore ? 'scaleY(-1)' : 'scaleY(1)' }" src="../../../../../assets/down.png" alt="" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="product-container">
                    <div class="product-item" v-for="(v, k) in demandList" :key="k" @click="toPage('/bigScreen/outcomeDetailDem?id=' + v.id)">
                        <div class="product-title">{{ v.name }}</div>
                        <div class="product-text two-lines">{{ v.demandIntroduce }}</div>
                        <div class="product-tag-box">
                            <div class="product-tag yellow">{{ v.demandIndustryType }}</div>
                            <!-- <div class="product-tag">{{ v.patentType }}</div> -->
                            <!-- <div class="product-tag">{{ v.grantTime || '暂无' }}</div> -->
                        </div>
                        <div class="star-box">
                            <div class="star-title" style="width: calc(100% - 17rem);">
                                联系人
                                <span>{{ v.demandCompanyPeople }}</span>
                            </div>
                            <div class="star-title" style="width: 17rem;">
                                联系电话
                                <span>{{ v.demandCompanyPhone }}</span>
                            </div>
                        </div>
                    </div>
                    <no-data v-if="!demandList.length" />
                </div>
                <div class="pagination-box">
                    <a-pagination :showSizeChanger='false' v-model:current="params2.number" v-model:pageSize="params2.size" :total="params2.total"
                        @change="onShowSizeChange2" />
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import headerBox from '../../../../../components/header.vue';
import headerImg from '../../../../../components/headerImg.vue';
import footerBox from '../../../../../components/footer-box.vue';
import { getAgentListMore } from '../../../../../api/gain.js';
import { messageAdd, getMessageDet } from '../../../../../api/message.js';
import noData from "../../../supermarket/components/no-data.vue"
import { useRouter } from 'vue-router';
import { baseUrl } from '../../../../../../config';
import { getarea } from '../../../../../api/home'
export default {
    components: {
        headerBox,
        headerImg,
        footerBox,
        noData
    },
    data() {
        return {
            headerKey: 0,
            arearShowMore: false,
            areaIndex: 0,
            areadata: [{ children: [] }],
            baseUrl,
            routers: useRouter(),
            typeIds: [null, null],
            typeList: [
                {
                    title: '类型',
                    fields: 'type',
                    showMore: false,
                    list: [
                        {
                            name: '技术开发',
                            id: 1
                        },
                        {
                            name: '技术推广',
                            id: 2
                        },
                        {
                            name: '技术服务',
                            id: 3
                        },
                        {
                            name: '产品研发',
                            id: 4
                        },
                        {
                            name: '策划服务',
                            id: 5
                        },
                        {
                            name: '企业孵化',
                            id: 6
                        },
                        {
                            name: '企业管理服务',
                            id: 7
                        },
                        {
                            name: '孵化器运营与管理',
                            id: 8
                        },
                        {
                            name: '科技企业孵化',
                            id: 9
                        }
                    ]
                },
            ],
            params: {
                number: 1,
                size: 10,
                total: 0,
                name: null,
                type: null,
                areaCode: null
            },
            resultList: [],
            ifChat: false,
            chatData: {},
            chatList: [],
            chatCon: null,
            msgId: null,
        }
    },
    mounted() {
        this.getList();
        this.getArear();
    },
    methods: {
        getArear() {
            getarea({}).then((res) => {
                if (res.code == 200) {
                    this.areadata = res.data
                    if (localStorage.getItem('orgInfo')) {
                        this.areaIndex =JSON.parse(localStorage.getItem('orgInfo')).areaIndex==-1?0:JSON.parse(localStorage.getItem('orgInfo')).areaIndex
                    }
                }
            })
        },
        getOrg() {
            var orgInfo = {}
            if (this.areaIndex == -1) {
                orgInfo = {}
            } else if (this.areaIndex == 0) {
                orgInfo = { orgId: this.areadata[0].id, areaIndex: this.areaIndex, areaName: '' }
            } else {
                orgInfo = { orgId: this.areadata[0].children[this.areaIndex].id, areaIndex: this.areaIndex, areaName: '' }
            }
            localStorage.setItem('orgInfo', JSON.stringify(orgInfo))
            this.getList();
            this.headerKey++
        },
        toPage(url) {
            this.routers.push(url);
        },
        setType(index, type, fields) {
            this.typeIds[index] = type.id;
            if (fields == 'transactionMoney') {
                this.params[fields] = type.id;
            } else {
                this.params[fields] = type.name;
            }
            this.getList();
        },
        getList() {
            var datas = { ...this.params }
            if (this.areaIndex == -1) {
                datas.orgFlag = '0'
            }
            getAgentListMore(datas).then(res => {
                if (res.code === 200) {
                    this.resultList = res.data.list;
                    this.params.total = res.data.total ? res.data.total : 0;
                }
            });
        },
        onkeydown(e) {
            if (e.key == 'Enter') {
                this.getList()
            }
        },
        onShowSizeChange(current, pageSize) {
            this.params.number = current
            this.params.size = pageSize
            this.getList()
        },
        gotoChat(v) {
            this.chatData = v;
            this.ifChat = true;
            this.msgId = v.id;
            this.getChatDet(v.id);
        },
        getChatDet(id) {
            getMessageDet({ receiveId: id }).then(res => {
                if (res.code === 200) {
                    this.chatList = res.data;
                }
            })
        },
        chatSub() {
            if (this.chatCon) {
                messageAdd({ content: this.chatCon, receiveId: this.msgId }).then(res => {
                    if (res.code === 200) {
                        this.chatCon = null;
                        this.getChatDet(this.msgId);
                    }
                })
            }
        },
gotoHome() {
            this.$router.push({
                path: '/bigScreenIndex',
            })
        },
        backToOne() {
            console.log('11');
            this.$router.go(-1)
        },
        goBack() {
            this.$router.push('/chart')
        }
    }
};
</script>

<style scoped lang="scss">
@font-face {
    font-family: "ffa";
    src: url(../../../assets/bigScreen/fonts/DS-DIGIB.TTF);
}
ul,
li {
    list-style: none;
}
.big-box {
    background-color: #071c3b;
    height: 100vh;
}
.header {
    position: relative;
    text-align: center;
    position: relative;
    height: 19.1rem;

    .backBox {
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 70rem;
        height: 10rem;
        cursor: pointer;
    }

    > img {
        width: 100%;
        max-height: 100%;
        margin-top: -1.1rem;
        image-rendering: -moz-crisp-edges; /* Firefox */
        image-rendering: -o-crisp-edges; /* Opera */
        image-rendering: -webkit-optimize-contrast; /* Webkit (non-standard naming) */
        image-rendering: crisp-edges;
        -ms-interpolation-mode: nearest-neighbor; /* IE (non-standard property) */
    }
}
.centerBox {
    width: 96%;
    margin: 0 auto;
    position: absolute;
    top: 14rem;
    left: 2%;
    .sreenTitle {
        background-image: url("../../../../../assets/bigScreen/sreenTitle.png");
        background-size: 100% 100%;
        height: 3.8rem;
        padding-left: 35px;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.85);
        display: flex;
        align-items: center;
    }
    .center {
        margin-top: 1rem;
        height: calc(100vh - 20rem);
        border: 1px solid;
        border-image: linear-gradient(
                130deg,
                #2385df 0%,
                rgba(35, 133, 223, 0.65) 92%
            )
            1;
        overflow-y: scroll;
        padding: 20px;

        .filter-box {
            width: 136rem;
            margin: 0 auto;
            margin-bottom: 20px;
            padding: 20px 40px;
            // background-color: #ffffff;
        }
        .filter-title-box {
            width: 100%;
            height: 60px;
            border-bottom: 1px solid #4494FF46;
        }
        .filter-title {
            line-height: 40px;
            float: left;
            font-size: 18px;
            font-weight: bold;
            color: #037aff;
        }
        .filter-input-box {
            width: 500px;
            height: 40px;
            float: right;
        }
        .filter-input {
            width: 380px;
            height: 40px;
            padding: 4px 20px;
            float: left;
            border-top: 1px solid #4494FF46;
            border-left: 1px solid #4494FF46;
            border-bottom: 1px solid #4494FF46;
        }
        .filter-input input {
            width: 340px;
            height: 30px;
            border: none;
            outline: none;
            background-color: transparent;
            color: rgba(255, 255, 255, 0.85);
        }
        .filter-btn {
            width: 120px;
            height: 40px;
            line-height: 40px;
            text-align: center;
            background: #037aff;
            border-top-right-radius: 4px;
            border-bottom-right-radius: 4px;
            float: left;
            font-size: 15px;
            color: #ffffff;
            cursor: pointer;
        }
        .filter-container {
            width: 100%;
            padding-top: 20px;
        }
        .filter-type {
            height: 55px;
            position: relative;
            padding-right: 90px;
            overflow: hidden;
            display: flex;
            flex-wrap: wrap;
        }
        .filter-more-btn {
            position: absolute;
            right: 0;
            top: 0;
            cursor: pointer;
            display: flex;
            align-items: center;
        }
        .filter-more-btn span {
            font-size: 16px;
            color: #037aff;
        }
        .filter-more-btn img {
            width: 10px;
            height: 5px;
            margin-left: 8px;
            margin-top: 8px;
        }
        .filter-type.last .filter-item {
            margin-bottom: 0;
        }
        .filter-type-title {
            display: inline-block;
            width: 9rem;
            margin-right: 40px;
            font-size: 17px;
            font-weight: bold;
            color: rgba(255, 255, 255, 0.85);
        }
        .filter-item {
            display: inline-block;
            margin-bottom: 30px;
            padding: 0 15px;
            height: 25px;
            line-height: 25px;
            border-radius: 4px;
            font-size: 16px;
            color: rgba(255, 255, 255, 0.85);
            cursor: pointer;
        }
        .filter-item.active {
            background-color: #037aff;
            color: #fff;
        }
        .broker-container {
            width: 136rem;
            height: max-content;
            margin: 3rem auto;
            display: flex;
            flex-wrap: wrap;
            .broker-item {
                width: 25.6rem;
                height: 36.4rem;
                margin-right: 2rem;
                margin-bottom: 2rem;
                background-color: #082853;
            border: 1px solid #4494FF46;
                padding: 2rem;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                cursor: pointer;
                &:nth-child(5n + 5) {
                    margin-right: 0;
                }
                .broker-img {
                    width: 14rem;
                    height: 14rem;
                    margin-bottom: 1.5rem;
                    img {
                        width: 100%;
                        height: 100%;
                        border-radius: 50%;
                        object-fit: cover;
                    }
                }
                .broker-name {
                    font-size: 2rem;
                    font-weight: bold;
                    color: rgba(255, 255, 255, 0.85);
                }
                .broker-text {
                    margin-top: 1.5rem;
                    margin-bottom: 2rem;
                    font-size: 1.5rem;
                    line-height: 2.5rem;
                    height: 5rem;
                    color: rgba(255, 255, 255, 0.85);
                    width: 100%;
                    .broker-text-item {
                        display: flex;
                        align-items: center;
                        flex-wrap: wrap;
                        align-items: center;
                        img {
                            width: 1.5rem;
                            height: auto;
                            margin-right: 0.5rem;
                        }
                        span {
                            display: block;
                            width: calc(100% - 2rem);
                            white-space: nowrap;
                            overflow: hidden;
                            text-overflow: ellipsis;
                        }
                    }
                }
                .broker-btn {
                    width: 100%;
                    line-height: 3.4rem;
                    border-radius: 4px;
                    background: #037dff;
                    text-align: center;
                    background-color: #037aff;
                    font-size: 1.6rem;
                    font-weight: bold;
                    color: #ffffff;
                    cursor: pointer;
                }
                &:last-child {
                    margin-right: 0;
                }
            }
        }
        .pagination-box {
            width: 100%;
            height: 10rem;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .qqMask {
            position: fixed;
            top: 0;
            left: 0;
            background-color: rgba(0, 0, 0, 0.8);
            width: 100%;
            height: 100%;
            z-index: 1;

            .chatk {
                width: 50%;
                height: 80%;
                position: fixed;
                top: 0;
                bottom: 0;
                left: 0;
                right: 0;
                margin: auto;
                background-color: rgba(255, 255, 255, 0.85);
                padding: 3rem 4rem;

                h4 {
                    font-size: 2rem;
                    line-height: 2.2rem;
                    color: #3d3d3d;
                    padding-bottom: 3rem;
                    border-bottom: 0.1rem solid #d8d8d8;

                    img {
                        width: 6rem;
                        height: 6rem;
                        margin-right: 3rem;
                        border-radius: 50%;
                        overflow: hidden;
                    }
                }

                .chat-record {
                    height: calc(100% - 9.1rem - 24rem - 4rem);
                    overflow: auto;
                    margin: 2rem 0;

                    /*滚动条样式*/
                    &::-webkit-scrollbar {
                        width: 4px;
                    }
                    &::-webkit-scrollbar-thumb {
                        border-radius: 10px;
                        box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
                        background: rgba(0, 0, 0, 0.2);
                    }
                    &::-webkit-scrollbar-track {
                        box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
                        border-radius: 0;
                        background: rgba(0, 0, 0, 0.1);
                    }

                    .record-li {
                        display: flex;
                        align-items: center;
                        justify-content: flex-end;
                        margin-bottom: 2rem;

                        .record-con {
                            font-size: 1.8rem;
                            line-height: 2.2rem;
                            color: rgba(255, 255, 255, 0.85);
                            padding: 2rem 5rem;
                            background-color: #037dff;
                            border-radius: 30rem;
                        }

                        .avater {
                            width: 6rem;
                            height: 6rem;
                            margin-left: 2rem;
                            border-radius: 50%;
                            overflow: hidden;

                            img {
                                width: 100%;
                                height: 100%;
                            }
                        }
                    }
                }

                .inputk {
                    position: relative;
                    height: 24rem;

                    .textareas {
                        padding: 3rem;
                        font-size: 1.8rem;
                        line-height: 2.2rem;
                        border-radius: 1.4rem;
                        width: 100%;
                        height: 100%;
                        padding-bottom: 7.5rem;
                        background: #f4f4f4;
                        border: none;
                    }

                    .inp-btn {
                        position: absolute;
                        bottom: 0;
                        right: 0;
                        display: flex;
                        align-items: center;
                        justify-content: flex-end;
                        width: 100%;
                        background-color: #f4f4f4;
                        padding: 0 2rem 2rem 0;

                        div {
                            border: 0.1rem solid #037dff;
                            font-size: 1.8rem;
                            color: #037dff;
                            border-radius: 0.4rem;
                            width: 14rem;
                            line-height: 4.8rem;
                            margin-left: 2rem;
                            text-align: center;
                            cursor: pointer;

                            &:last-child {
                                background-color: #037dff;
                                color: rgba(255, 255, 255, 0.85);
                            }
                        }
                    }
                }
            }
        }
    }
    ::-webkit-scrollbar {
        width: 5px;
        height: 10px;
    }

    /* 滚动条轨道 */
    ::-webkit-scrollbar-track {
        background-color: #234470;
    }

    /* 滚动条滑块 */
    ::-webkit-scrollbar-thumb {
        background-color: #061c57;
    }

    /* 鼠标悬停在滚动条上的滑块 */
    ::-webkit-scrollbar-thumb:hover {
        background-color: #555;
    }
}
.backToBox {
    position: absolute;
    top: 8rem;
    right: 2%;
    display: flex;
    .backTo {
        background-image: url("../../../../../assets/bigScreen/backTo.png");
        color: #2dccff;
        background-size: 100% 100%;
        width: fit-content;
        padding: 2px 40px 10px 10px;
        font-weight: 600;
        cursor: pointer;
        margin-left: 10px;
        div {
            padding-top: 5px;
        }
    }
}::v-deep {
    .ant-btn-primary {
        border-color: #037aff;
        background: #037aff;
    }

    .ant-input {
        background: rgba(68, 148, 255, 0.12);
        border: none;
        color: #ffffff;
    }

    .ant-pagination-item {
        background: rgba(8, 26, 48, 0.8);
        border: 1px solid #0b2f5f;
    }

    .ant-pagination-item a {
        color: #ffffff;
    }

    .ant-pagination-prev .ant-pagination-item-link,
    .ant-pagination-next .ant-pagination-item-link {
        background: rgba(8, 26, 48, 0.8);
        border: 1px solid #0b2f5f;
        color: #707981;
    }

    .ant-pagination-disabled .ant-pagination-item-link {
        background: rgba(8, 26, 48, 0.8);
        border: 1px solid #0b2f5f;
        color: #707981;
    }

    .ant-pagination-item-active {
        background: #004dfd;
        border-radius: 2px;
        border: none;
    }

    .ant-pagination-jump-prev
        .ant-pagination-item-container
        .ant-pagination-item-ellipsis,
    .ant-pagination-jump-next
        .ant-pagination-item-container
        .ant-pagination-item-ellipsis {
        color: #ffffff;
    }
    .ant-select-selector {
        background-color: transparent !important;
        background: rgba(8, 26, 48, 0.8) !important;
        border: 1px solid #0b2f5f !important;
        color: #ffffff !important;
    }
}
</style>
